<template>
  <div class="mod-user">
    <el-dialog
      :close-on-click-modal="false"
      :visible.sync="visible"
      width="40%">
      <h3>提示：填写信息前请确认您已经联系过获奖用户,并且已经寄出相关奖品</h3>
      <el-tabs type="border-card">
        <el-tab-pane label="奖励发放">
          <el-form :inline="true" :model="dataForm" ref="dataForm" :rules="dataRule" class="data-form">
            <el-row >
              <el-form-item label="收件人姓名:">
                <el-input v-model="dataForm.recipientName" placeholder="收件人姓名" style="width:300px"></el-input>
              </el-form-item>
            </el-row>

            <el-row >
              <el-form-item label="联系方式:">
                <el-input v-model="dataForm.contactInformation" placeholder="联系方式" style="width:300px"></el-input>
              </el-form-item>
            </el-row>

            <el-row>
              <el-form-item label="联系地址:">
                <el-input v-model="dataForm.contactAddress" placeholder="联系地址" style="width:300px"></el-input>
              </el-form-item>
            </el-row>

            <el-row>
              <el-form-item label="物流单号:">
                <el-input v-model="dataForm.logisticsNumber" placeholder="物流单号" style="width:300px"></el-input>
              </el-form-item>
            </el-row>
            <el-row>
              <el-form-item label="发放操作:">
                <div align="left" style="float: left">
                  <el-button @click="rewardHandle()">确定</el-button>
                </div>
              </el-form-item>
            </el-row>
          </el-form>
        </el-tab-pane>
      </el-tabs>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data () {
    return {
      dataForm: {
        userlogId: '',
        recipientName: '',
        contactInformation: '',
        contactAddress: '',
        logisticsNumber: ''
      },
      dataRule: {
      },
      visible: false
    }
  },
  methods: {
    init (id) {
      debugger
      this.visible = true
      this.dataForm.userlogId = id
      console.log(id)
      console.log(this.dataForm.userlogId)
    },
    // 表单提交
    rewardHandle () {
      debugger
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          this.$confirm(`确定发放操作?`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.$http({
              url: this.$http.adornUrl(`/userlog/addIssueLogInfo`),
              method: 'post',
              data: this.$http.adornData({
                'userlogId': this.dataForm.userlogId || undefined,
                'recipientName': this.dataForm.recipientName,
                'contactInformation': this.dataForm.contactInformation,
                'contactAddress': this.dataForm.contactAddress,
                'logisticsNumber': this.dataForm.logisticsNumber
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refschGetDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          })
        }
      })
    }
  }
}
</script>
<style>
  .el-upload__tip {
    margin-left: 277px;
  }
</style>
